package struts.util;

import java.lang.reflect.Field;

import javax.servlet.http.HttpServletRequest;

import struts.bean.vo.StrutsXmlVO;

public class FullBeanUtil {
	public FullBeanUtil(){
		
	}
	/**
	 * 遍历对象属性，然后进行赋值
	 * @param request
	 * @return
	 */
	public static Object full(HttpServletRequest request,StrutsXmlVO vo){
		Object o=null;
		try {
			Class clazz=Class.forName(vo.getBeanClass());
			o=clazz.newInstance();
			Field [] fields=clazz.getDeclaredFields();
			for(Field f:fields){
				f.setAccessible(true);
				f.set(o,request.getParameter(f.getName()));
				f.setAccessible(false);
			}
			
		} catch (Exception e) {
			e.printStackTrace();
		}
		return o;
	}
	
}
